//
//  LBViewController.m
//  LBNetworking
//
//  Created by WuShiHai on 19/5/30.
//  Copyright (c) 2019 Lebbay. All rights reserved.
//

#import "LBViewController.h"
#import <LBNetworking/LBNetworking.h>
#import "LBHTTPProtocolImpl.h"
#import <CocoaLumberjack/CocoaLumberjack.h>
#import <LBNetworking/LBNetworking.h>
#import <YYModel/YYModel.h>
#import <LBNetworking/LBBaseRequest.h>

//static const DDLogLevel ddLogLevel = ;

@interface LBViewController ()

@end

@implementation LBViewController

- (NSString *)defaultAppIdentifier{
    NSString *bundleIdentifier = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"];
    bundleIdentifier = [[[[[bundleIdentifier stringByReplacingOccurrencesOfString:@"hoc" withString:@""] stringByReplacingOccurrencesOfString:@"hoc" withString:@""] stringByReplacingOccurrencesOfString:@"pl" withString:@""] stringByReplacingOccurrencesOfString:@".dev" withString:@""] stringByReplacingOccurrencesOfString:@"dev" withString:@""];
    return bundleIdentifier;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    LBBaseRequest *baseRequest = [LBBaseRequest defaultRequest:@"1"];
    NSLog(@"baseRequest ====> %@", [baseRequest yy_modelToJSONString]);
    
    
    LBHTTPConfiguration *configuration = [LBHTTPConfiguration defaultConfiguration];
    configuration.timeoutInterval = 20;
    configuration.response.dataKey = @"data";
    LBHTTPSessionManager *manager = [LBHTTPSessionManager manager:@"http://www.baidu.com"
                                                    configuration:configuration
                                                         protocol:[LBHTTPProtocolImpl class]];
    
    NSURLSessionDataTask *task = [manager POST:@"test/demo"
                                    parameters:nil
                               completeHandler:^(NSError * _Nullable error, LBHTTPResponse * _Nonnull response) {
                                   
                               }];
    [self addTask:task];
    
    LBHTTPConfiguration *new_configuration = [LBHTTPConfiguration defaultConfiguration];
    new_configuration.timeoutInterval = 20;
    new_configuration.response = configuration.response;
    NSURLSessionDataTask *new_task = [manager request:WDHTTPSessionMethodPOST
                                            URLString:@"test/demo"
                                           parameters:nil
                                        configuration:new_configuration
                                      completeHandler:^(NSError * _Nullable error, LBHTTPResponse * _Nonnull response) {
                                          
                                      }];
    [self addTask:new_task];

	// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
